package com.ibm.crl.sb.thread.others.example;
import java.util.concurrent.Callable;  
import java.util.concurrent.ExecutionException;  
import java.util.concurrent.FutureTask;  
public class CallableThread {  
    public static void main(String[] args) {  
        FutureTask<Integer[]> ft = new FutureTask<Integer[]>(new MyCallable(3));  
        new Thread(ft).start();  
        try {  
            Integer[] output=(Integer[])ft.get();  
            for(int i=0;i<output.length;i++)  
            {  
                System.out.println(output[i]);  
            }  
        } catch (InterruptedException e) {  
            // TODO Auto-generated catch block  
            e.printStackTrace();  
        } catch (ExecutionException e) {  
            // TODO Auto-generated catch block  
            e.printStackTrace();  
        }  
          
    }  
}  
class MyCallable implements Callable<Integer[]> {  
    private int max;  
    public MyCallable(int i) {  
        this.max = i;  
    }  
    @Override  
    public Integer[] call() throws Exception {  
        // TODO Auto-generated method stub  
        Integer[] count = new Integer[max];  
        for (int i = 0; i < max; i++) {  
            count[i] = 10 + i + 200;  
        }  
        return count;  
    }  
}  